package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookCoinRewardHistory;
import com.pgybook.db.entity.domain.BookCoinRewardHistoryEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookCoinRewardHistoryMapper {
    int countByExample(BookCoinRewardHistoryEx example);

    int deleteByExample(BookCoinRewardHistoryEx example);

    @Delete({
            "delete from bookcoinrewardhistory",
            "where BOOKCOINREWARDHISTORYID = #{bookcoinrewardhistoryid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long bookcoinrewardhistoryid);

    @Insert({
            "insert into bookcoinrewardhistory (CUSTID, REWARDTYPE, ",
            "PROCESSTYPE, AMOUNT, ",
            "STAFFID, BOOKID, ",
            "BOOKINSTANCEID, MEMO, ",
            "CRTTIME, UPDTIME, ",
            "STATUS)",
            "values (#{custid,jdbcType=BIGINT}, #{rewardtype,jdbcType=INTEGER}, ",
            "#{processtype,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, ",
            "#{staffid,jdbcType=INTEGER}, #{bookid,jdbcType=INTEGER}, ",
            "#{bookinstanceid,jdbcType=INTEGER}, #{memo,jdbcType=VARCHAR}, ",
            "#{crttime,jdbcType=TIMESTAMP}, #{updtime,jdbcType=TIMESTAMP}, ",
            "#{status,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "bookcoinrewardhistoryid", before = false, resultType = Long.class)
    int insert(BookCoinRewardHistory record);

    int insertSelective(BookCoinRewardHistory record);

    List<BookCoinRewardHistory> selectByExample(BookCoinRewardHistoryEx example);

    @Select({
            "select",
            "BOOKCOINREWARDHISTORYID, CUSTID, REWARDTYPE, PROCESSTYPE, AMOUNT, STAFFID, BOOKID, ",
            "BOOKINSTANCEID, MEMO, CRTTIME, UPDTIME, STATUS",
            "from bookcoinrewardhistory",
            "where BOOKCOINREWARDHISTORYID = #{bookcoinrewardhistoryid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    BookCoinRewardHistory selectByPrimaryKey(Long bookcoinrewardhistoryid);

    int updateByExampleSelective(@Param("record") BookCoinRewardHistory record, @Param("example") BookCoinRewardHistoryEx example);

    int updateByExample(@Param("record") BookCoinRewardHistory record, @Param("example") BookCoinRewardHistoryEx example);

    int updateByPrimaryKeySelective(BookCoinRewardHistory record);

    @Update({
            "update bookcoinrewardhistory",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "REWARDTYPE = #{rewardtype,jdbcType=INTEGER},",
            "PROCESSTYPE = #{processtype,jdbcType=INTEGER},",
            "AMOUNT = #{amount,jdbcType=DECIMAL},",
            "STAFFID = #{staffid,jdbcType=INTEGER},",
            "BOOKID = #{bookid,jdbcType=INTEGER},",
            "BOOKINSTANCEID = #{bookinstanceid,jdbcType=INTEGER},",
            "MEMO = #{memo,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "STATUS = #{status,jdbcType=INTEGER}",
            "where BOOKCOINREWARDHISTORYID = #{bookcoinrewardhistoryid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookCoinRewardHistory record);
}
